/*
package com.jymj.controller;

import com.jymj.entity.zjd.ApplyChildEntity;
import com.jymj.entity.zjd.ApplyChildFileEty;
import com.jymj.entity.zjd.ApplyEntity;
import com.jymj.service.ApplyChildFileService;
import com.jymj.service.ApplyChildService;
import com.jymj.service.ApplyService;
import com.jymj.service.YlService;
import com.jymj.utils.PageUtils;
import com.jymj.utils.Query;
import com.jymj.utils.R;
import com.jymj.common.validator.ValidatorUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

*/
/**
 * Created by ljj on 2018/9/12.
 *//*

@RestController
@RequestMapping("/applyChild")
public class ApplyChildController extends AbstractController {
    @Autowired
    private ApplyChildService applyChildService;
    @Autowired
    private ApplyService applyService;
    @Autowired
    private YlService ylService;
    @Autowired
    private ApplyChildFileService applyChildFileService;
    */
/**
     * 查询 通过4 列表
     * @return
     *//*

    @RequestMapping("/list")
    @ResponseBody
    public R list(@RequestBody Map<String, Object> params){
        Query query = new Query(params);
        query.put("code",getUser().getCode());
        List<ApplyEntity>  applyEntities = applyService.queryRemv19List(query);
        List<ApplyEntity> appList  = new ArrayList<>();
        int total = applyService.queryRemv19Total(query);

        PageUtils pageUtil = new PageUtils(appList, total, query.getLimit(), query.getPage());

        return R.ok().put("data", pageUtil);
    }
    */
/**
     * 查询详情
     * @return
     *//*

    @RequestMapping("/info")
    @ResponseBody
    public R info(@RequestBody Map map){
        Integer applyId = null;
        if (map.containsKey("applyId") && map.get("applyId") != null){
            applyId = Integer.valueOf(map.get("applyId").toString());
        }
        ApplyEntity applyEntity =  applyService.queryObject(applyId);
        ApplyChildEntity applyChildEty = applyChildService.queryObject(applyId);
        if(applyChildEty!=null && applyChildEty.getAppid()!=null){
            List<ApplyChildFileEty> applyChildFileEties = applyChildFileService.getqueryList(applyId);
            if(applyChildFileEties.size()>=1){
                applyChildEty.setApplyChildFileEtyList(applyChildFileEties);
            }
            applyEntity.setApplyChildEntity(applyChildEty);
        }
        return R.ok().put("data",applyEntity);
    }


    */
/**
     * 添加施工信息  来开始施工状态
     * @return
     *//*

    @RequestMapping("/save")
    @ResponseBody
    public R save(@RequestBody ApplyChildEntity applyChildEntity){
        //校验类型
        ValidatorUtils.validateEntity(applyChildEntity);
        applyChildEntity.setQrsgdate(new Date());
        applyChildEntity.setSgtype(71);
        applyChildService.save(applyChildEntity);
        //修改申请项目的状态  和yl颜色  ---》改为施工状态7
        ApplyEntity applyEntity = new ApplyEntity();
        applyEntity.setId(applyChildEntity.getAppid());
        applyEntity.setSgdate(applyChildEntity.getQrsgdate());
        applyEntity.setSptype(7);
        applyService.updateStype(applyEntity);
        ylService.updateYlByAppId(applyEntity.getId());
        Integer appChildId = applyChildEntity.getId();
        return R.ok().put("data",applyChildEntity);
    }

    @RequestMapping("/update")
    @ResponseBody
    public R update(@RequestBody ApplyChildEntity applyChildEntity){
        //校验类型
        ValidatorUtils.validateEntity(applyChildEntity);
        if(applyChildEntity.getSgtype()!=null && applyChildEntity.getSgtype()==71){
            ApplyEntity applyEntity = new ApplyEntity();
            applyEntity.setId(applyChildEntity.getAppid());
            applyEntity.setSgdate(applyChildEntity.getQrsgdate());
            applyEntity.setSptype(7);
            applyService.updateStype(applyEntity);
        }
        applyChildService.update(applyChildEntity);
        return R.ok().put("data",applyChildEntity);
    }

    */
/**
     * 71（确认）-->72（进场）-->73（完成）-->74 (待验收) 进行下一步
     * @return
     *//*

    @RequestMapping("/next")
    @ResponseBody
    public R next(@RequestBody Map map){
        Integer appChildId = null;
        if (map.containsKey("appChildId") && map.get("appChildId") != null){
            appChildId = Integer.valueOf(map .get("appChildId").toString());
        }
        Integer sgtype = null;
        if (map.containsKey("sgtype") && map.get("sptype") != null){
            sgtype = Integer.valueOf(map .get("sgtype").toString());
        }

        ApplyChildEntity applyChildEntity = applyChildService.queryByChid(appChildId);

            if(sgtype==70){
                return R.ok("true").put("data",applyChildEntity);
            }
            boolean istrue = applyChildService.next(appChildId,sgtype);
            if(istrue){
                if(sgtype<applyChildEntity.getSgtype()){
                    return R.ok("true").put("data",applyChildEntity);
                }
                applyChildEntity.setId(appChildId);
                sgtype=sgtype+1;
                if(sgtype==74){
                    ApplyEntity applyEntity = new ApplyEntity();
                    applyEntity.setId(applyChildEntity.getAppid());
                    applyEntity.setSptype(8);
                    applyEntity.setDysdate(new Date());
                    applyService.updateStype(applyEntity);
                }
                applyChildEntity.setSgtype(sgtype);
                applyChildService.update(applyChildEntity);
                return R.ok("true").put("data",applyChildEntity);
            }
            else {
                if(sgtype<applyChildEntity.getSgtype()){
                    if(applyChildEntity.getSgtype()==74){
                        ApplyEntity applyEntity = new ApplyEntity();
                        applyEntity.setId(applyChildEntity.getAppid());
                        applyEntity.setSptype(7);
                        applyEntity.setDysdate(new Date());
                        applyService.updateStype(applyEntity);
                    }
                    applyChildEntity.setId(appChildId);
                    applyChildEntity.setSgtype(sgtype);
                    applyChildService.update(applyChildEntity);
                }
                return R.ok("false");
            }
    }

}
*/
